package com.hjm.common.utils;

import com.alibaba.fastjson.JSONObject;
import com.hjm.common.utils.request.HttpClientUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName UpstreamMerInfo
 * @Deacription 获取上游商户信息
 * @Version 1.0
 **/
public class UpstreamMerInfo {

    //public static String RESULT =  "{\"msg\":\"OK\",\"termList\":[{\"brhNo\":\"61025001\",\"propTp\":\"1\",\"consume\":\"1\",\"originalTid\":\"100000000508413\",\"prepaidCard\":\"1\",\"termId\":\"10022189\",\"search\":\"0\",\"debitCard\":\"0\",\"termAddr\":\"北京市石景山区古城南街22号靠近绿地环球文化金融城\",\"preauthorize\":\"0\",\"creditCard\":\"1\",\"semiCreditCard\":\"1\",\"termNm\":\"北京市石景山区个体王正龙\",\"productCd\":\"0000290228049669\",\"termTp\":\"0\",\"contTel\":\"13521393722\",\"refund\":\"0\"}],\"merchantInfo\":{\"certType\":\"01\",\"originalMid\":\"100000000508413\",\"freeSign\":\"0\",\"settleBindTel\":\"13521393722\",\"settlTN\":\"0\",\"addrProvince\":\"1000\",\"mcc\":\"5969\",\"mchtStatus\":\"0\",\"applyId\":\"1002359741\",\"openMall\":\"1\",\"settleBankNm\":\"上海浦东发展银行北京海淀园支行\",\"contact\":\"王正龙\",\"mchtType\":\"03\",\"cashFeeTp\":\"1\",\"clearType\":\"1\",\"busType\":\"1\",\"cashFeeInvstIntrst\":\"0.000\",\"certExpdate\":\"20220120\",\"artifCertifTpActCon\":\"01\",\"mchtNm\":\"北京市石景山区个体王正龙\",\"openDays\":\"0\",\"pastime\":\"20201027\",\"mchtNo\":\"848102559696477\",\"addrCounty\":\"1025\",\"settlTp\":\"0\",\"unionQrcodeDebitAmt\":\"-1\",\"qqFee\":\"0.38\",\"licenceNo\":\"\",\"feeType\":\"1\",\"fullThreshold\":\"10.00\",\"addrCity\":\"1000  \",\"certNo\":\"341225199206076317\",\"emporiumPreferenceDebitFee\":\"0.58\",\"wechatFee\":\"0.38\",\"managerActCon\":\"王正龙\",\"unionQrcodeCreditFee\":\"0.38\",\"cashFeeAmt\":\"0.00\",\"compaddr\":\"\",\"dcRate\":\"0.13\",\"ccMax\":\"-1\",\"identityNoActCon\":\"341225199206076317\",\"rateFlag\":\"1\",\"unionQrcodeSweptFlag\":\"1\",\"commTel\":\"13521393722\",\"dcMax\":\"35.00\",\"emporiumPreferenceCreditFee\":\"0.58\",\"speSettleTp\":\"01\",\"alipayFee\":\"0.38\",\"compaddrActCon\":\"北京市石景山区古城南街22号靠近绿地环球文化金融城\",\"cashFlag\":\"1\",\"faceCreditFlag\":\"1\",\"prolDateActCon\":\"20220120\",\"feeRateDNfc\":\"0.38\",\"aiFlag\":\"1\",\"addr\":\"北京市石景山区古城南街22号靠近绿地环球文化金融城\",\"taxNo\":\"\",\"brhNo\":\"61025001\",\"manager\":\"王正龙\",\"licenceEndDate\":\"\",\"unionQrcodeDebitFee\":\"0.38\",\"ccRate\":\"0.53\",\"operNo\":\"000001\",\"settleAcctNo\":\"6217920688411565\",\"settleAcctNm\":\"王正龙\",\"cashTp\":\"2\",\"fullMsg\":\"王正龙,01,10.00,1,0.38,0.38,0.38,0.58,0.58,-1,848102559696477,1002359741,1,61025001,000001,2,1,5969,北京市石景山区古城南街22号靠近绿地环球文化金融城,上海浦东发展银行北京海淀园支行,100000000508413,王正龙,341225199206076317,13521393722,6217920688411565,北京市石景山区个体王正龙,1,1,1000,1000  ,1025,1,0.000,0.00,1,0.38,-1,0.38,1,1,0.38,0.38,1,北京市石景山区个体王正龙,王正龙,王正龙,01,341225199206076317,20220120,北京市石景山区古城南街22号靠近绿地环球文化金融城,03,20201027,01,20220120,1,13521393722,310100000157,0.13,35.00,0.53,-1,1,1\",\"mchtCnAbbr\":\"北京市石景山区个体王正龙\",\"compliance\":\"1\",\"bankBranchNo\":\"310100000157\",\"feeRateCNfc\":\"0.38\",\"emporiumPreferenceDebitAmt\":\"-1\",\"alipaySweptFlag\":\"1\",\"wildCard\":\"1\"},\"status\":\"0000\"}";
    public static final String URL = "http://192.168.1.27:8899/getMerchant";
    private static Logger logger = LogManager.getLogger("resultPack");


   /**
    *
    * @Param [merNo   商户编号]
    * @Param [applyId 商户工单号]
    * @Param [url     请求路径]
    * @Return void
    */
   public static JSONObject getMerchant(String merNo, String applyId, String url) throws Exception{
        Map<String, Object> params = new HashMap<>();
        //商户号
       params.put("originalId", merNo);
       //订单号
       params.put("applyId", applyId);
       logger.info("请求===============》" + JSONObject.toJSONString(params));
       JSONObject getMerchant = HttpClientUtils.sendHttpPostJson(url, params);
       logger.info("响应===============》" + getMerchant);
       return getMerchant;
   }


    public static JSONObject getMerchantFj(String merNo, String applyId, String url) throws Exception {
        Map<String, Object> params = new HashMap<>();
        //商户号
        params.put("originalId", merNo);
        //订单号
        params.put("applyId", applyId);
        logger.info("请求===============》" + JSONObject.toJSONString(params));
        String getMerchant = HttpUtils.sendNetSfJson(url,
                net.sf.json.JSONObject.fromObject(params),
                "utf-8");
        JSONObject jsonObject1 = JSONObject.parseObject(getMerchant);
        logger.info("响应===============》" + getMerchant);
        return jsonObject1;
    }


    public static void main(String[] args) throws Exception {
        //String merNo = "100000000590372";
        String merNo = "100000000508413";
        String applyId = "1002359741";
        //String applyId = "100001006564832";


    }


}
